package com.gateway.bootstrap.config;

import com.gateway.bootstrap.handler.GatewayRouteDataHandler;
import com.gateway.bootstrap.listener.GatewayRouteInitListener;
import com.gateway.repository.service.GatewayRouteDefinitionService;
import org.springframework.cloud.gateway.route.RouteDefinitionRepository;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @program: api-gateway
 * @description:
 * @author: YuKai Fan
 * @create: 2025/2/6 15:47
 **/
@Configuration
public class GatewayBootstrapConfiguration {

    @Bean
    public GatewayRouteDataHandler routeDataHandler(
            final ApplicationEventPublisher publisher,
            final RouteDefinitionRepository routeDefinitionRepository) {
        return new GatewayRouteDataHandler(publisher, routeDefinitionRepository);
    }

    @Bean
    public GatewayRouteInitListener gatewayRouteInitListener() {
        return new GatewayRouteInitListener();
    }
}
